﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.Register.Application.Commonds.TraceabilityManagementCommonds;
using Traceability.Register.ErrorCode.Result;

namespace Traceability.Register.Read.API.Controllers
{
    /// <summary>
    /// 溯源管理显示控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TraceabilityManagementsController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;
        /// <summary>
        /// 构造函数依赖注入
        /// </summary>
        /// <param name="mediator">中介者</param>
        public TraceabilityManagementsController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 显示分页
        /// </summary>
        /// <param name="param">请求</param>
        /// <returns>返回任务</returns>
        [HttpGet]
        public async Task<ApiResult> GetShow([FromQuery]TraceabilityManagementShowCommond param)
        {
            return await mediator.Send(param);
        }
        /// <summary>
        /// 显示省份
        /// </summary>
        /// <param name="param">请求</param>
        /// <returns>返回任务</returns>
        [HttpGet]
        public async Task<ApiResult> GetProvin([FromQuery]ProvinCommond param)
        {
            return await mediator.Send(param); 
        }
        /// <summary>
        /// 显示城市
        /// </summary>
        /// <param name="param">请求</param>
        /// <returns>返回任务</returns>
        [HttpGet]
        public async Task<ApiResult> GetCity([FromQuery]CityCommond param)
        {
            return await mediator.Send(param);
        }
        /// <summary>
        /// 显示县区
        /// </summary>
        /// <param name="param">请求</param>
        /// <returns>返回结果</returns>
        [HttpGet]
        public async Task<ApiResult> GetCounty([FromQuery]CountyCommond param)
        {
            return await mediator.Send(param);
        }
    }
}
